package com.leboncoin.util;

import java.text.DecimalFormat;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FormatManager {

    static final Logger logger = Logger.getLogger(FormatManager.class.getName());

    public static String formatNumberWithSpaces(Integer number) {
        String result = null;
        try {
            DecimalFormat formatter = new DecimalFormat("#,##0.###");
            result = formatter.format(number);
            result = result.replace((char) 160, ' '); //Remplace l'espace insecable par un espace normal
        } catch (IllegalArgumentException e) {
            logger.log(Level.SEVERE, "Cannot convert {0} to string", number);
        }
        return result;
    }
}
